public class MallardDuck extends Duck {
    public MallardDuck(){
        super("绿色",1.2);
    }

    public MallardDuck(double heavy){
        super("绿色",heavy);
    }

    @Override
    public void fly(){
        System.out.println("绿头鸭展翅高飞，飞得很远");
    }

    @Override
    public void quack(){
        System.out.println("绿头鸭发出响亮的‘嘎嘎嘎’叫声");
    }

    public void setHeavy(double heavy, String unit){
        if ("kg".equalsIgnoreCase(unit)){
            this.heavy = heavy;
        }else if("g".equalsIgnoreCase(unit)){
            this.heavy = heavy/1000.0;
        }
        System.out.println("绿头鸭重量设置为：" + heavy + unit);
    }

    public void setHeavy(double minHeavy, double maxHeavy){
        this.heavy = (minHeavy + maxHeavy)/2;
        System.out.println("绿头鸭平均重量设置为：" + this.heavy + "kg(范围：" + minHeavy + "-" + maxHeavy + "kg");
    }
}
